<?php
include('include/config.inc.php');   
$categoryId          = isset($_GET['categoryId']) ? $_GET['categoryId'] : 0;       //Variable for selection of Item
$subCategoryId       = isset($_GET['subCategoryId']) ? $_GET['subCategoryId'] : 0; //Variable for selection of Item
$itemArr['itemId']   = array();                                                    //Variable for selection of Item
$itemArr['itemName'] = array();                                                    //Variable for selection of Item
// Logic runs only when Sub-Category is changed from main tpl and to get value of Item Names : Starts
$subCategoryQuery = "SELECT itemId,itemName
                       FROM item
                      WHERE 1 = 1";
if($categoryId > 0  && $subCategoryId > 0)
{
$subCategoryQuery .= " AND categoryId	 = ".$categoryId."
                       AND subCategoryId	 = ".$subCategoryId;
}
elseif($categoryId > 0)
{
$subCategoryQuery .= " AND categoryId	 = ".$categoryId;
}
elseif($subCategoryId > 0)
{
$subCategoryQuery .= " AND subCategoryId	 = ".$subCategoryId;
}
$subCategoryQuery .= " AND status = 'A' ORDER BY itemName ";
$subCategoryQueryRes = mysql_query($subCategoryQuery);
$j = 0;
while($subCategoryRow = mysql_fetch_array($subCategoryQueryRes))
{
  $itemArr['itemId'][$j]   = $subCategoryRow['itemId'];
  $itemArr['itemName'][$j] = substr_replace($subCategoryRow['itemName'],'...',40);
  $j++;
}
// Logic runs only when Sub-Category is changed from main tpl and to get value of Item Names : Ends
$smarty->assign("subCategoryId",$subCategoryId);
$smarty->assign("itemArr",$itemArr);
$smarty->display("itemFilterAj.tpl");
?>